package com.bosicloud.cmb.ibp.aws.adapter.service;

import com.bosicloud.cmb.ibp.aws.adapter.commom.dto.CreateApiResultDTO;
import com.bosicloud.cmb.ibp.aws.adapter.commom.dto.DeployApiParamDTO;
import com.bosicloud.cmb.ibp.aws.adapter.commom.dto.DeployApiResultDTO;
import com.bosicloud.cmb.ibp.aws.adapter.commom.vo.ApiKeyVO;

import java.io.IOException;

/**
 * @author Jack Peng / ziliang.peng@bosicloud.com
 */
public interface ApiGatewayService {

    /**
     * 创建API KEY
     * @param userId 用户ID
     * @param isTest 是否测试Key
     * @return 创建Key的信息
     */
    ApiKeyVO createApiKey(Integer userId, boolean isTest);

    /**
     * 导入Swagger定义的API资源
     * 1. 更新Endpoint占位符;
     * 2. 更新为需要API Key;
     * @param jsonUrl URL
     * @param failOnWarnings 忽略警告
     * @return 创建结果
     * @throws IOException
     */
    CreateApiResultDTO createApiGateway(String jsonUrl, boolean failOnWarnings) throws IOException;

    /**
     * 部署API
     * @param deployApi API ID
     * @return 部署结果
     */
    DeployApiResultDTO deployApi(DeployApiParamDTO deployApi);

    /**
     * 订阅API
     * @param keyId API Key ID
     * @param usagePlanId 使用计划ID
     * @return
     */
    String subscribeApi(String keyId, String usagePlanId);

    /**
     * 取消订阅
     * @param keyId KeyID
     * @param usagePlanId UP ID
     * @return 成功 or 失败
     */
    String unsubscribeApi(String keyId, String usagePlanId);

    /**
     * 删除API(已部署不能删除)
     * @param awsApiId APIID
     * @return 是否已经删除
     */
    boolean deleteApiGateway(String awsApiId);
}
